home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / exec / funsyste.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  1.0 KB  |  45 lines

  1. /*
  2. \funcref{fun\_system}{void fun\_system ()}
  3.     {}
  4.     {}
  5.     {}
  6.     {fun\_exec()}
  7.     {funsyste.c}
  8.     {
  9.  
  10.         This function expects a system string as last pushed {\em e\_str}
  11.         value. The string is executed through a {\em system()} call (if this
  12.         fails, an error is issued).
  13.  
  14.     }
  15. */
  16.  
  17. #include "icm-exec.h"
  18.  
  19. void fun_system ()
  20. {
  21.     register char
  22.         *sys;                    /* cmd string */
  23.     register int
  24.         ret,                    /* system() return */
  25.         mode;                    /* P_CHECK wanted? */
  26.  
  27.     mode = stack [sp].vu.intval;        /* get mode arg */
  28.     sys = stack [sp - 1].vu.i->ls.str;        /* get cmd string */
  29.  
  30.     if (echo)                    /* re-echo if requested */
  31.         puts (sys);
  32.     fflush (stdout);
  33.  
  34. #ifdef MSDOS
  35.     _heapmin ();                /* max memory under DOS */
  36. #endif
  37.     
  38.     ret = system (sys);                /* do system call */
  39.     if (ret && P_CHECKMODE (mode))        /* terminate upon failure? */
  40.         error ("system - failure of system call (status %d)", ret);
  41.         
  42.     reg.type = e_int;                /* return result as */
  43.     reg.vu.intval = ret;            /* e_int */
  44. }
  45.